Home

Operator Usage

Name

TM-learn-sentences

Description

TM-learn-sentences[splitter] sp
for each ket in the input sp,
split into a sequence using the given splitter operator
then learn the corresponding sentence sequences
with respect to the operators: sentence-raw, sentence-template, sentence-length, sentence-type, sentence-value
where:
sentence-raw is the unprocessed sentence
sentence-template is the raw sequence
sentence-length is the number of kets in that sequence
sentence-type is extract-head applied to the raw sequence
sentence-value is extract-value applied to the raw sequence
Note, it keeps track of the number of existing sentence nodes so as not to stomp on them
And if a given sentence is already known, then it is skipped
this operator is a member of the Template Machine set of operators


Examples

-- learn some words to types maps:
-- first, the default is return itself:
map |*> #=> |_self>

-- now some specific cases (add more as needed):
map |The> => |#DET#>
map |a> => |#DET#>
map |man> => |#NOUN#>

-- now build the splitter operator:
apply-map |*> #=> tensor-product[": "] (map |_self> . |_self>) 
splitter |*> #=> apply-map ssplit[" "] |_self>

-- now invoke it all with a couple of toy sentences:
TM-learn-sentences[splitter] (|The old man sat on a bench> + |The young man walked>)

-- now see what we know using the dump operator:
dump(|*>) rel-kets[*]
    map |*> #=> |_self>
    apply-map |*> #=> tensor-product[": "](map |_self> . |_self> )
    splitter |*> #=> apply-map ssplit[" "] |_self>

    map |The> = > |#DET#>
    map |a> = > |#DET#>
    map |man> = > |#NOUN#>

    sentence-template |sentence: 1> => |#DET#: The> . |old: old> . |#NOUN#: man> . |sat: sat> . |on: on> . |#DET#: a> . |bench: bench>
    sentence-length |sentence: 1> => |7>
    sentence-type |sentence: 1> => |#DET#> . |old> . |#NOUN#> . |sat> . |on> . |#DET#> . |bench>
    sentence-value |sentence: 1> => |The> . |old> . |man> . |sat> . |on> . |a> . |bench>

    sentence-template |sentence: 2> => |#DET#: The> . |young: young> . |#NOUN#: man> . |walked: walked>
    sentence-length |sentence: 2> => |4>
    sentence-type |sentence: 2> => |#DET#> . |young> . |#NOUN#> . |walked>
    sentence-value |sentence: 2> => |The> . |young> . |man> . |walked>


See also

Operator type

sequence compound context